<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>每日任务</title>
    <link rel="stylesheet" href="css/my.css"> <!-- 公共样式 -->
    <link rel="stylesheet" href="css/signInPcBC.css">  <!-- 私有样式 -->
    <link rel="stylesheet" href="css/elementui.css">
    <!-- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">  elementui -->
    <script type="text/javascript" src="js/jweixin-1.3.2.js"></script>  <!-- 微信sdk -->
    <script type="text/javascript" src="js/rem.js"></script>  <!-- 适配js -->
    <script type="text/javascript" src="js/vue.js"></script>  <!-- vue.js -->
    <script type="text/javascript" src="js/axios.min.js"></script>  <!-- axios.js -->
    <script src="js/elementui.js"></script>  <!-- elementui -->
   
</head>
<body>
    <div id="app" class="app">
      <!-- 顶部 -->
      <div class="top dis">
        <div class="priceBox dis">
           <img :src="startUrl+'/svg//pcPrice.png'" alt="">
           <p>{{priceAll}}</p>
        </div>
        <div class="title">本周已累计签到&nbsp;{{signObj.additionDays}}&nbsp;天</div>
      </div>

      <!-- 签到模块 -->
      <div class="signBox">
         <div class="signWeek disp">
          <div v-for="(item,index) in signObj.dailyCheckInWeekVOList" :key="index">
           <div class="signItem1" v-if="item.signInStatus==2">
            <div class="signItemTop">
                <img :src="startUrl+'/svg/pcSignYes.png'" alt="">
            </div>
            <div class="fontFolor1">{{index==0?'周一':index==1?'周二':index==2?'周三':index==3?'周四':index==4?'周五':index==5?'周六':'周日'}}</div>
          </div>
          <div class="signItem2" v-if="item.signInStatus==3">
              <div class="signItemTop">
                <div class="go">GO</div>
              </div>
            <div class="fontFolor2">{{index==0?'周一':index==1?'周二':index==2?'周三':index==3?'周四':index==4?'周五':index==5?'周六':'周日'}}</div>
          </div>
          <div class="signItem3" v-if="item.signInStatus==1">
              <div class="signItemTop">
                 <div class="addPrice">+{{parseInt(item.arrayGoCoin)||0}}</div>
              </div>
              <div class="fontFolor1">{{index==0?'周一':index==1?'周二':index==2?'周三':index==3?'周四':index==4?'周五':index==5?'周六':'周日'}}</div>
            </div>
           </div>
         </div>
         <div class="signBottom disp">
           <p class="p1">每日签到&nbsp;得1GO币</p>
           <p class="p2 active" class="btnColor1" v-if="isBigSign==1">已签到</p>
           <p class="p2" @click="signBtn" v-else>签到</p>
         </div>
      </div>
      
      <!-- 每日任务 -->
      <div class="tasks dis">
          <div class="tasksBj">
              <img :src="startUrl+'/svg/pc_foot_bj.png'" alt="">
              <p>每日任务</p>
          </div>
          <div class="list">
              <div class="listItem disp" v-for="(item,index) in Tasks" :key="item.id">
                  <div class="left dis">
                    <p class="p1">{{item.title}}</p>
                    <p class="p2">+{{item.price}}&nbsp;GO币</p>
                  </div>
                  <div class="right btnColor1" v-if="item.giftStatus==2&&index!=3">已领取</div>
                  <div class="right btnColor2" v-if="item.giftStatus==1&&index!=3" @click="receive(item)">领GO币</div>
                  <div class="right btnColor3" v-if="item.giftStatus==0&&index!=3" @click="toOk(item)">去完成</div>
                  <div v-if="index==3" class="active">请前往小程序进行分享</div>
                </div>
          </div>
      </div>

      <!-- 完善简历 -->
      <div class="tasks dis">
          <div class="tasksBj">
              <img :src="startUrl+'/svg/pc_foot_bj.png'" alt="">
              <p>完善简历</p>
          </div>
          <div class="list">
              <div class="listItem disp" v-for="item in perfect" :key="item.id">
                  <div class="left dis">
                    <p class="p1">{{item.title}}</p>
                    <p class="p2">+{{item.price}}&nbsp;GO币</p>
                  </div>
                  <div class="right btnColor1" v-if="item.giftStatus==2">已领取</div>
              <div class="right btnColor2" v-if="item.giftStatus==1" @click="receive(item)">领GO币</div>
              <div class="right btnColor3" v-if="item.giftStatus==0" @click="toOk(item)">去完成</div>
               </div>
          </div>
      </div>

    </div>
    <script>
      var vm = new Vue({
            el: "#app", //挂载点
            data: {
              // config:"http://job-dev.gogowork.cn:4080/gogojob-ucenter",
              config:"/gogojob-ucenter",
              startUrl:"https://job-img.gogowork.cn/static/img",
              priceAll:0,
              isBigSign:"",
              Tasks:[], // 每日任务
              perfect:[], // 完善信息
              signObj:{}, //签到模块
            },
            methods: {
              // 签到
              signBtn(){
                axios({
                  url:this.config+"/activity/signinweekly/dailyAttendance",
                  method:"post",
                  headers: {
                    'token':this.getParameterByName("token")
                  },
                  data:{
                    activityId:1,
                    companyId:0
                  } 
                }).then(res=>{
                  if(res.data.code==200){
                    this.$message.success('GO币+'+res.data.data)
                    this.getSignList()
                  }else{
                    this.$message.warning(res.data.msg)
                  }
                }).catch(err=>{
                  this.$message.error("网络请求异常")
                })
              },
              // 领go币
              receive(item){
                axios({
                  url:this.config+"/activity/taskconfig/claimDailyTasks",
                  method:"post",
                  headers: {
                    'token':this.getParameterByName("token")
                  },
                  data:{
                    tasksId:item.id,
                    groupId:item.groupId,
                    activityId:1,
                    companyId:0
                  } 
                }).then(res=>{
                  if(res.data.code==200){
                    item.giftStatus = 2;
                    this.$message.success('GO币+'+res.data.data)
                    this.priceAll = this.priceAll+parseInt(res.data.data)
                  }else{
                    this.$message.warning(res.data.msg)
                  }
                }).catch(err=>{
                  this.$message.error("网络请求异常")
                })
              },
               // 去完成
              toOk(item){
                window.open("/#"+item.url)
              },
              // 获取参数
              getParameterByName(name, url) {
                if (!url) url = window.location.href;
                name = name.replace(/[\[\]]/g, "\\$&");
                var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
                results = regex.exec(url);
                if (!results) return null;
                if (!results[2]) return "";
                return decodeURIComponent(results[2].replace(/\+/g, " "));
              },
              // 获取签到列表
              getSignList(){
                axios({
                  url:this.config+"/activity/signinweekly/signinweeklylist",
                  method:"post",
                  headers: {
                    'token':this.getParameterByName("token")
                  },
                  data:{
                    companyId:0,
                    activityId:1
                  } 
                }).then(res=>{       
                  if(res.data.code==200){
                     this.signObj = res.data.data;
                     this.isBigSign = res.data.data.isBigSign;
                     this.priceAll = parseInt(res.data.data.availableAll)||0
                  }else{
                    this.$message.warning(res.data.msg)
                  }
                }).catch(err=>{
                  this.$message.error("网络请求异常")
                })
              },
              // 获取列表
              getList(groupId){
               axios({
                  url:this.config+"/activity/taskconfig/dailyTasksList",
                  method:"post",
                  headers: {
                    'token':this.getParameterByName("token")
                  },
                  data:{
                    groupId:groupId,
                    companyId:0,
                    activityId:1
                  } 
                }).then(res=>{                  
                  if(res.data.code==200){
                     if(groupId==1){
                       this.Tasks = res.data.data;
                     }else{
                       this.perfect = res.data.data;
                     }
                  }else{
                    this.$message.warning(res.data.msg)
                  }
                }).catch(err=>{
                  this.$message.error("网络请求异常")
                })
              }
            },
            watch: { //监听
            
            },
            computed: { //计算属性
              
            },
            filters: { 

            },
            created(){
          
            },
            mounted() {
              this.getList(1)
              this.getList(2)
              this.getSignList()
            }
        })
    </script>
</body>
</html>